<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        *{
            margin:0;
            padding:0;
        }
        .form{
            width:300px;
            height:400px;
            border:1px solid #333;
            text-align: center;
        }
        ul{
            height:50px;
            border-bottom: 1px solid #333;
            list-style: none;
        }
        li{
            display: inline-block;
            line-height: 50px;
            cursor: pointer;
        }
        .content{
            height:350px;
            position: relative;
        }
        .content>div{
            position: absolute;
            width:100%;
            height:100%;
        }
        .two{
            display: none;
        }
        .two>img{
            width:100%;
            height: 100%;
        }
        .current{
            color:orangered;
        }
    </style>
</head>
<body>
    <div class="form">
        <ul>
            <li class="current">账号登录</li>
            <li>扫码登录</li>
        </ul>
    
        <div class="content">
            <div class="one">
                <p>账号登录</p>
            </div>
            <div class="two">
                <img src="images/placeholder.png" alt="">
            </div>
        </div>
    </div>
    <script>
        var lis = document.getElementsByTagName("li");
        var contents = document.querySelectorAll(".content>div");
        for(let i = 0;i<lis.length;i++){
            lis[i].onclick = function(){
                //1.点击tab变色
                for(var k=0;k<lis.length;k++){
                    lis[k].className = "";
                }
                this.className = "current";
                //2.让对应的content出现
                for(let i=0;i<contents.length;i++){
                    contents[i].style.display = "none";
                }
                contents[i].style.display = "block";
            }
        }
    </script>

</body>
</html>